package com.forekonw.demo5;

/**
 * 类：具有相同属性和行为的一个模板
 */
public class Student {
    //属性（变量）
    String sid;
    String name;
    int age;
    String school;
    //行为（方法）
    public void syudy() {
        System.out.println("study......");
    }

    public void eat() {
        System.out.println("eat......");
    }

    public void sleep() {
        System.out.println("sleep......");
    }

    public void game() {
        System.out.println("game......");
    }

    public static void main(String[] args) {
        //如果想用类里面的方法就要先创建student类的对象
        Student stu1 = new Student();
        //如何调用对象中的属性和方法
        //给stu1 的对象和属性赋值
        stu1.sid = "s10001";
        stu1.name = "tom";
        stu1.age = 12;
        stu1.school = "shenyang";
        //调用对象中的方法
        stu1.syudy();
        stu1.eat();
        stu1.game();
        stu1.sleep();
        System.out.println(stu1.sid+"---------"+stu1.name+"------"+stu1.school);

        Student stu2 = new Student();
        stu2.sid = "s10002";
        stu2.name = "tony";
        stu2.age = 12;
        stu2.school = "dalian";
        stu2.sleep();
        stu2.eat();
        stu2.game();
        System.out.println(stu2.school);

        Student stu3 = new Student();

    }
}
